package com.itheima.bos.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.itheima.bos.bean.base.Courier;
import com.itheima.bos.dao.CourierDao;
import com.itheima.bos.service.CourierService;

@Service
@Transactional
public class CourierServiceImpl implements CourierService {

	@Autowired
	private CourierDao dao;

	@Override
	public void save(Courier courier) {
		dao.save(courier);
	}

	@Override
	public Page<Courier> findPageData(Specification<Courier> specification, Pageable pageable) {
		return dao.findAll(specification, pageable);

	}

	@Override
	public Page<Courier> findPageQueryCourierByCondition(Specification<Courier> specification, Pageable pageable) {
		// TODO Auto-generated method stub
		return dao.findAll(specification, pageable);
	}

	@Override
	public void delBatch(String[] idsArr) {
		for (String id : idsArr) {
			Integer id2 = Integer.parseInt(id);
			dao.updateDelTag(id2);
		}
	}

	@Override
	public void restoreBatch(String[] idsArr) {
		for (String id : idsArr) {
			Integer id2 = Integer.parseInt(id);
			dao.updateRestoreBatch(id2);
		}
	}

	@Override
	public List<Courier> findAll() {
		// TODO Auto-generated method stub
		return dao.findAll();
	}

}
